using UnityEngine;
using System.Collections;
/// <summary>
/// Orthello Controller base class
/// </summary>
public class OTController {

    /// <summary>
    /// this controller runs at this speed (.5f=half speed, 1=normal, 2=twice as fast).
    /// </summary>
    public float speed = 1;
    /// <summary>
    /// enable/disable this controller.
    /// </summary>
    public bool enabled = true;
    /// <summary>
    /// controller name.
    /// </summary>
    public string name
    {
        get
        {
            return _name;
        }
    }
    /// <summary>
    /// running time
    /// </summary>
    public float time
    {
        get
        {
            return _time;
        }
    }

    /// <exclude />
    protected object owner;
    /// <exclude />
    protected string _name;
    /// <exclude />
    protected float deltaTime;
    /// <exlude />
    protected float _time;

    /// <summary>
    /// Controller constructor
    /// </summary>
    /// <param name="owner">object that this controller will influence</param>
    /// <param name="name">controller name</param>
    public OTController(object owner, string name)
    {
        this.owner = owner;
        this._name = name.ToLower();
    }

    /// <summary>
    /// Override this method to handle the controller when subclassing the base.
    /// </summary>
    protected virtual void Update()
    {
    }

    /// <exclude />
    public void Update(float pDeltaTime)
    {
        deltaTime = pDeltaTime * speed;
        if (enabled)
            Update();
        _time += deltaTime;
    }
    /// <summary>
    /// Set timerecording of this controller to 0
    /// </summary>
    public void ResetTime()
    {
        _time = 0;
    }

}
